home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------
- | Big-print:
- | Texte auf Din A 4 Druckern ausgeben,
- | die größer als ein Blatt sind.
- |
- |
- --------------------------------------*/
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- #include "..\wwlib.src\file_io.h"
-
-
- #define PAPER_ROW 72 /* Reihen */
- #define PAPER_CLM 80 /* Spalten */
-
-
- #define max(a, b) ((a) > (b) ? (a) : (b))
- #define min(a, b) ((a) <= (b) ? (a) : (b))
-
- /*------------
- | Eingabe-File
- --------------*/
- char *text;
-
- /*----------
- | Text-Größe
- ------------*/
- int cc, rc;
-
-
- /*----------
- | Prototypen
- ------------*/
- void get_text_size( char *t );
- void print_text( void );
- void print_page( int r, int c);
-
-
- main(int argc, char **argv)
- {
- char p[130];
- char n[130];
- char *t;
-
- if( argc != 2)
- { printf("\nbig_print, usage: bprn input_file");
- exit( 1 );
- }
-
- strcpy( p, argv[1] );
- strcpy( n, t = get_name( p ) );
- /* xxx schmuddelig */
- *(t-1) = '\0';
-
- text = (char *)load_file( p, n, "r" );
- if( text == NULL )
- { printf( "\nnot found: %s%s", p, n);
- exit( 2 );
- }
-
- get_text_size( text );
-
- print_text( );
-
- unload_file( text );
-
- return 0;
-
- }
-
- /*---------------------------------------
- | Textgröße ( Zeilen und Spalten ) holen
- -----------------------------------------*/
- void get_text_size( char *t )
- {
- long c;
- int ac;
-
-
- ac = cc = rc = 0;
-
- for( c = 0; c < act_fil_sz; c++)
- {
- if( t[c] == '\n' )
- { cc = max( ac, cc );
- ac = 0;
- rc++;
- }
- }
- }
-
-
-
- /*-------------------------
- | Text drucken, alle Seiten
- ---------------------------*/
- void print_text( void )
- {
- int row;
- int clm;
-
- row = 0;
-
-
- do
- {
- do
- {
- clm = 0;
-
- print_page( row, clm);
- clm = min( clm + PAPER_CLM, cc );
- }while( clm < cc );
-
- row = min( row + PAPER_ROW, rc);
- }while( row < rc );
- }
-
-
-
- /*-------------------
- | Seite drucken
- |--------------------
- | Ab Zeile r
- | ab der c'ten Spalte
- ---------------------*/
- void print_page( int r, int c)
- {
- int t;
- long p;
- int y;
-
-
- /*--------------------------
- | PAPER_ROW Zeilen ausgeben,
- | maximal bis Textende!
- ----------------------------*/
- for( y = r; y < r + PAPER_ROW && y < rc; y++ )
- {
- /*-------------------------
- | p auf Zeile #y ausrichten
- ---------------------------*/
- for( p = 0; p < y; p++)
- { if( text[p] == '\n' )
- { p--;
- }
- }
-
- /*--------------------------------------
- | In dieser Zeile c Zeichen überspringen
- | maximal bis Zeilenende!
- ----------------------------------------*/
- for( t = 0; t < c; t ++)
- { if( text[ p + t] == '\n' )
- { break;
- }
- }
-
-
- /*--------------------------
- | PAPER_CLM Zeichen ausgeben
- ----------------------------*/
- for( ; t < t + PAPER_CLM; t++ )
- {
- /*----------------
- | Zeichen ausgeben
- ------------------*/
- printf("%c", text[ p + t]);
- /*-----------------------
- | Maximal bis Zeilenende!
- -------------------------*/
- if( text[ p + t] == '\n' )
- { break;
- }
- }
- }
- }
-